define(function(require, exports, module){
	require("resource/js/easyui/easyloader.js");
	var AJAX = require("resource/js/component/ajax.js");
	var sectionId = sessionStorage.getItem('sectionId');  //获取标段id

	
	var initpage = function(){
		var option={
				time:$("#gridTime").val(),
				sectionId:sectionId,
    	   };
		AJAX.init().success(function(code,msg,data){
    		if(code==0){
    			$("#projectName").text(data.master.projectName);
    			$("#sectionName").text(data.master.sectionName);
    			$("#layerName").text(data.master.layerName);
    			$(".materialName").text(data.master.materialName);
    			$("#TPJStartTime").text(data.master.TPJStartTime);
    			$("#TPJEndTime").text(data.master.TPJEndTime);
    			$("#TPJStartMileage").text(data.master.TPJStartMileage);
    			$("#TPJEndMileage").text(data.master.TPJEndMileage);
    			$("#TPJMileage").text(data.master.TPJMileage);
    			$("#seriousSegregation").text(formatConversion(data.master.seriousSegregation));
    			$("#mildSegregation").text(formatConversion(data.master.mildSegregation));
    			$("#notSegregation").text(formatConversion(data.master.notSegregation));
    			$("#avgTPJTemperature").text(formatConversion(data.master.avgTPJTemperature));
    			$("#maxTPJTemperature").text(formatConversion(data.master.maxTPJTemperature));
    			$("#minTPJTemperature").text(formatConversion(data.master.minTPJTemperature));
    			$("#coeTPJTemperature").text(formatConversion(data.master.coeTPJTemperature));
    			$("#avgTPJSpeed").text(formatConversion(data.master.avgTPJSpeed));
    			$("#maxTPJSpeed").text(formatConversion(data.master.maxTPJSpeed));
    			$("#minTPJSpeed").text(formatConversion(data.master.minTPJSpeed));
    			$("#coeTPJSpeed").text(formatConversion(data.master.coeTPJSpeed));
    			$("#YLJStartTime").text(data.master.YLJStartTime);
    			$("#YLJEndTime").text(data.master.YLJEndTime);
    			$("#YLJStartMileage").text(data.master.YLJStartMileage);
    			$("#YLJEndMileage").text(data.master.YLJEndMileage);
    			$("#warningPercent").text(formatConversion(data.master.warningPercent));
    			applyReport();
    			for(var i in data.rollerPass){
    				if(data.rollerPass[i].rollerType=="胶轮压路机"){
    					$("#jl_lessTargetPercent").text(formatConversion(data.rollerPass[i].lessTargetPercent));
    					$("#jl_equalTargetPercent").text(formatConversion(data.rollerPass[i].equalTargetPercent));
    					$("#jl_greaterTargetPercent").text(formatConversion(data.rollerPass[i].greaterTargetPercent));
    					$("#jl_underRate").text(formatConversion(data.rollerPass[i].underRate));
    					$("#jl_overRate").text(formatConversion(data.rollerPass[i].overRate));
    				}else{
    					$("#gl_lessTargetPercent").text(formatConversion(data.rollerPass[i].lessTargetPercent));
    					$("#gl_equalTargetPercent").text(formatConversion(data.rollerPass[i].equalTargetPercent));
    					$("#gl_greaterTargetPercent").text(formatConversion(data.rollerPass[i].greaterTargetPercent));
    					$("#gl_underRate").text(formatConversion(data.rollerPass[i].underRate));
    					$("#gl_overRate").text(formatConversion(data.rollerPass[i].overRate));
    				}
    			}
    			for(var k=0; k<	data.roller.length;k++){
    				var tempData = data.roller[k];
    				$("<tr><td>"+tempData.rollerName+"</td><td>"+tempData.rollerType+"</td>" +
    				  "<td class='textColor'>"+formatConversion(tempData.avgYLJSpeed)+"</td><td class='textColor'>"+formatConversion(tempData.avgYLJTemperature) +"</td>" +
    				  "<td class='textColor'>"+formatConversion(tempData.overloadPercent) +"</td></tr>").appendTo($("#yljReport"));
    			}
    		}
    	}).post(BASEPATH + '/dcs/report/queryStatisticsReportTotal.htm', option);
	}
	
	var formatConversion = function(res){
		if(isNaN(Number(res))){
			return res;
		}else{
			return Number(res).toFixed(2);
		}
	}
	
	var applyReport = function(){
		var option={
				time:$("#gridTime").val(),
				sectionId:sectionId,
	    	};
		AJAX.init().success(function(code,msg,data){
			if(code==0){
				$(".lessTargetPass_bs").text("<"+data.lessTargetPass);
				$(".greaterTargetPass_bs").text(">"+data.greaterTargetPass);
				$(".nomarlTargetPercent_bs").text(data.lessTargetPass+"~"+data.greaterTargetPass);
				$("#gl_equalTargetPass").text(data.lessTargetPass+"~"+data.greaterTargetPass);
				$("#jl_equalTargetPass").text(data.lessTargetPass+"~"+data.greaterTargetPass);
			}
		}).post(BASEPATH + '/roller/statistics/queryRollerNumber.htm', option);
	}
	
	module.exports = {
		trans:function(){
		   initpage();
		}
	}
});
